<template>
  <div id="seteventdetails">
    <fieldset class="layui-elem-field layui-field-title">
      <legend>模块类型</legend>
      <div class="layui-field-box">
        <el-radio-group v-model="radio">
          <el-radio-button label="显示标题"></el-radio-button>
          <el-radio-button label="不显示标题"></el-radio-button>
        </el-radio-group>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title">
      <legend>模块标题</legend>
      <div class="layui-field-box">
        <el-input v-model="moddata.config.title" placeholder="请输入模块标题"></el-input>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title" v-if="pageConfig[pageConfig.theme].layout == 'two'">
      <legend>模块位置</legend>
      <div class="layui-field-box">
        <el-radio-group v-model="moddata.belong">
          <el-radio label="left">左侧</el-radio>
          <el-radio label="right">右侧</el-radio>
        </el-radio-group>
      </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title">
      <legend>字体颜色</legend>
      <div class="layui-field-box">
        <el-color-picker v-model="color"></el-color-picker>
      </div>
    </fieldset>
    <el-button @click="save" type="primary">保存</el-button>
    <el-button @click="cancel">取消</el-button>
  </div>
</template>

<script>
  import {
    mapState,
    mapMutations
  } from 'vuex'
  export default {
    // props: ["moddata", "index","pageconfig"],
    // data: function () {
    //   return {
    //     input: this.moddata[this.index].config.title,
    //     radio: this.moddata[this.index].config.titleshow ? "显示标题" : "不显示标题",
    //     color2: this.moddata[this.index].config.fontcolor
    //   }
    // },
    computed: {
      ...mapState([
        "container",
        "setindex",
        "pageConfig"
      ]),
      moddata() {
        return this.container.items[this.setindex]
      },
      input: {
        get() {
          return this.$store.state.container.items[this.$store.state.setindex].config.title
        },
        set(value) {
          this.setModConfig({
            index: this.setindex,
            key: 'title',
            value: value
          })
        }
      },
      radio: {
        get() {
          return this.$store.state.container.items[this.$store.state.setindex].config.titleshow ? "显示标题" : "不显示标题"
        },
        set(value) {
          if (value == "显示标题") {
            this.setModConfig({
              index: this.setindex,
              key: 'titleshow',
              value: true
            })
          } else if (value == "不显示标题") {
            this.setModConfig({
              index: this.setindex,
              key: 'titleshow',
              value: false
            })
          }
        }
      },
      color: {
        get() {
          return this.$store.state.container.items[this.$store.state.setindex].config.fontcolor
        },
        set(value) {
          this.setModConfig({
            index: this.setindex,
            key: 'fontcolor',
            value: value
          })
        }
      }
    },
    methods: {
      // changetype: function () {
      //   if (this.radio == "显示标题") {
      //     this.moddata[this.index].config.titleshow = true;
      //   } else if (this.radio == "不显示标题") {
      //     this.moddata[this.index].config.titleshow = false;
      //   }
      // },
      // changefc: function () {
      //   this.moddata[this.index].config.fontcolor = this.color2
      // },
      ...mapMutations(['setModConfig', 'cancelEdit']),
      cancel: function () {
        this.cancelEdit();
      },
      save: function () {
        this.$store.dispatch('save')
      }
    }
  }
</script>

<style>

</style>